package pnlBeheer;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import tblLSListner.TMSLCategorie;
import tblModelCategorie.TMCategorie;
import controllerCat.*;



public class PnlCatBeheer extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4071812396686572257L;

	public JPanel pnlTbl;
	public JTable tblCat;
	public JScrollPane scroll;
	
	public JLabel lblTitle;
	public JLabel lblNaam;
	public JLabel lblNieuwNaam;
	public JLabel lblSaveMelding;
	public JLabel LblDeleteMelding;

	
	public JTextField txtNaam;
	public JTextField txtNieuwNaam;
	
	public ImageIcon imgSave;
	public ImageIcon imgUpdate;
	public ImageIcon imgDelete;
	
	public JButton btnsaveNew;
	public JButton btnsaveOld;
	public JButton btndelete;

	public CatBtnSave cbs;
	public CatBtnUpdate cbu;
	public CatBtnDelete cbd;
	
	public TMCategorie tmCat;
	public TMSLCategorie tmslCat;
	
	
	public PnlCatBeheer(){
		
		this.cbs = new CatBtnSave(this);
		this.cbu = new CatBtnUpdate(this);
		this.cbd = new CatBtnDelete(this);
		this.tmCat = new TMCategorie(this);
		this.tmslCat = new TMSLCategorie(this);
		

		
		setBackground(Color.WHITE);
		setSize(1365,600);
		setVisible(true);
		setLayout(null);
		
		lblTitle = new JLabel("<html><h1><b>Categorie beheer</b></h1></html>");
		lblTitle.setBounds(50, 50, 300, 40);
		add(lblTitle);
		
		lblNaam = new JLabel("Naam");
		lblNaam.setBounds(50, 150, 100, 20);
		add(lblNaam);
		
		lblNieuwNaam = new JLabel("Nieuwe naam");
		lblNieuwNaam.setBounds(50, 200, 100, 20);
		add(lblNieuwNaam);
		
		txtNaam = new JTextField();
		txtNaam.setBounds(150, 150, 200, 20);
		add(txtNaam);
		
		txtNieuwNaam = new JTextField();
		txtNieuwNaam.setBounds(150, 200, 200, 20);
		add(txtNieuwNaam);
		
		pnlTbl = new JPanel();
		pnlTbl.setLayout(new BorderLayout());
		pnlTbl.setBounds(600, 80, 700, 580);
		add(pnlTbl);
		
		String []names = {"Naam"};
		Object [][] obj = {{"Haaivinnensoep"}};
		
		tblCat = new JTable(obj,names);
		tblCat.setBounds(0,0,600,0);
		tblCat.getSelectionModel().addListSelectionListener(tmslCat);
		tblCat.setModel(tmCat);
		
		scroll = new JScrollPane(tblCat);
		pnlTbl.add(scroll);
		
		lblSaveMelding = new JLabel("Categorie is toegevoegd.");
		lblSaveMelding.setBounds(200, 120, 150, 20);
		lblSaveMelding.setForeground(Color.red);
		lblSaveMelding.setVisible(false);
		add(lblSaveMelding);
		
		LblDeleteMelding = new JLabel("Categorie is verwijderd.");
		LblDeleteMelding.setBounds(200, 120, 150, 20);
		LblDeleteMelding.setForeground(Color.red);
		LblDeleteMelding.setVisible(false);
		add(LblDeleteMelding);
		
		imgSave = new ImageIcon(getClass().getResource("/image/save.gif"));
		btnsaveNew = new JButton("Save",imgSave);
		btnsaveNew.setHorizontalTextPosition(JButton.CENTER);
		btnsaveNew.setVerticalTextPosition(JButton.BOTTOM);
		btnsaveNew.setBounds(30, 450, 100, 90);
		btnsaveNew.setOpaque(false);
		btnsaveNew.setContentAreaFilled(false);
		btnsaveNew.setBorderPainted(false);
		btnsaveNew.setFocusPainted(false);
		btnsaveNew.addActionListener(cbs);
		btnsaveNew.setActionCommand("Save");
		add(btnsaveNew);
		
		imgUpdate = new ImageIcon(getClass().getResource("/image/update.gif"));
		btnsaveOld = new JButton("Update",imgUpdate);
		btnsaveOld.setHorizontalTextPosition(JButton.CENTER);
		btnsaveOld.setVerticalTextPosition(JButton.BOTTOM);
		btnsaveOld.setBounds(110, 450, 100, 90);
		btnsaveOld.setOpaque(false);
		btnsaveOld.setContentAreaFilled(false);
		btnsaveOld.setBorderPainted(false);
		btnsaveOld.setFocusPainted(false);
		btnsaveOld.addActionListener(cbu);
		btnsaveOld.setActionCommand("Update");
		add(btnsaveOld);
		
		
		imgDelete = new ImageIcon(getClass().getResource("/image/trash.gif"));
		btndelete = new JButton("Delete",imgDelete);
		btndelete.setHorizontalTextPosition(JButton.CENTER);
		btndelete.setVerticalTextPosition(JButton.BOTTOM);
		btndelete.setBounds(190, 450, 100, 90);
		btndelete.setOpaque(false);
		btndelete.setContentAreaFilled(false);
		btndelete.setBorderPainted(false);
		btndelete.setFocusPainted(false);
		btndelete.addActionListener(cbd);
		btndelete.setActionCommand("Delete");		
		add(btndelete);
		
		
	}


	public JTextField getTxtNieuwNaam() {
		return txtNieuwNaam;
	}


	public void setTxtNieuwNaam(JTextField txtNieuwNaam) {
		this.txtNieuwNaam = txtNieuwNaam;
	}


	public JLabel getLblNieuwNaam() {
		return lblNieuwNaam;
	}


	public void setLblNieuwNaam(JLabel lblNieuwNaam) {
		this.lblNieuwNaam = lblNieuwNaam;
	}


	public JTable getTblCat() {
		return tblCat;
	}


	public void setTblCat(JTable tblCat) {
		this.tblCat = tblCat;
	}


	public JLabel getLblSaveMelding() {
		return lblSaveMelding;
	}


	public void setLblSaveMelding(JLabel lblSaveMelding) {
		this.lblSaveMelding = lblSaveMelding;
	}


	public JLabel getLblDeleteMelding() {
		return LblDeleteMelding;
	}


	public void setLblDeleteMelding(JLabel lblDeleteMelding) {
		LblDeleteMelding = lblDeleteMelding;
	}


	public JTextField getTxtNaam() {
		return txtNaam;
	}


	public void setTxtNaam(JTextField txtNaam) {
		this.txtNaam = txtNaam;
	}	
}